import { defineStore } from 'pinia';
import { REMOVE_TOKEN } from '../../utils/token';
import { ref } from 'vue';
import { reqLogin } from '@/api/login';
import router from '@/router';

export const useStudentStore = defineStore('studentId', () => {
    // 请假列表
    const leaveList = ref([]);
    //姓名
    const studentName = ref('');
    //学号
    const studentNum = ref();
    //班主任姓名
    const headTeatherName = ref('');
    //班级
    const className = ref('');
    //是否成年
    const have18th = ref(false);
    //限制状态
    const restrictState = ref(1);
    const $reset = () => {
        leaveList.value = [];
        studentName.value = '';
        studentNum.value = '';
        headTeatherName.value = '';
        className.value = '';
        have18th.value = false;
        restrictState.value = 0;
    };
    const login = data => {
        localStorage.setItem('userType', 'student');
        studentName.value = data.userName;
        studentNum.value = data.userNum;
        headTeatherName.value = data.headTeatherName;
        className.value = data.className;
        have18th.value = data.have18th;
        restrictState.value = data.restrictState;
    };
    const logout = $reset;

    return {
        studentName,
        studentNum,
        headTeatherName,
        className,
        have18th,
        restrictState,
        leaveList,
        login,
        logout
    };
});
